
//License Information
/*
    Copyright 2010 Jozsef Jantek

    This file is part of HunterTC.

    HunterTC is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    HunterTC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with HunterTC.  If not, see <http://www.gnu.org/licenses/>.
*/

package huntertc;


public class Shot
{
    public String name="Combat", shot_info="";
    public int school=0, focus=0, avg_dmg=0, cooldown=0, gcd=100, bon_dmg=0, bon_crit=0, crit_dmg=0;
    protected int base_cast = 0, act_cast=0, dps=0, dpm=0;
    public int tick=1, tick_rate=0;
    public int dmg_done=0, opt_dmg=0, opt_dmg_dr=0, ev=0, avg_hit=0, ev_hit=0, avg_crit=0, ev_crit=0;
    /*
    School:
    0 - Physical
    1 - Fire
    2 - Arcane
    3 - Nature
    4 - Shadow
    5 - Bleed
    */
    public void Calc(Char_sheet schar){}

    public void Opt_Dmg(Char_sheet schar)
    {
        if(tick==1 || name=="Explosive Shot")
        opt_dmg=(int)(((getCrit(schar)*(FinalCrit(schar)))+(((float)100-(getCrit(schar)+schar.getMiss()))*Final(schar)))/100);
        else opt_dmg=(int)((float)avg_dmg*getFinalBon(schar));
        
        if(school==0) opt_dmg_dr=(int)((float)opt_dmg*schar.getPenDR());
        else if(school==5) opt_dmg_dr=opt_dmg;
        else opt_dmg_dr=(int)((float)opt_dmg*schar.getMR());

    }

    public float getCrit(Char_sheet schar)
    {
        return schar.getCrit()+(float)bon_crit;
    }

    public float getFinalBon(Char_sheet schar)
    {
        return schar.getBonDmg()+getBon_dmg();
    }

    public float CountDPS()
    {
        float sdps=0;
        if(cooldown==0&&getAct_cast()==0) sdps=0;
        else if(cooldown>getAct_cast())
            sdps=(float)avg_dmg*tick/cooldown;
        else sdps=(float)avg_dmg*tick/getAct_cast();
        return sdps;
    }

    public float CountDPM()
    {
        float sdpm=0;
        if(focus>0) sdpm=(float)avg_dmg*tick/focus;
        return sdpm;
    }

    public int Final(Char_sheet schar)
    {
        int s=avg_dmg;
        s=(int)((float)s*getFinalBon(schar));
        return s;
    }

    public int FinalDR(Char_sheet schar)
    {
        int s=Final(schar);
        if(school==0) s=(int)((float)s*schar.getPenDR());
        else if(school!=5) s=(int)((float)s*schar.getMR());
        return s;
    }

    public int FinalCrit(Char_sheet schar)
    {
        int s=avg_dmg;
        s=(int)((float)s*getFinalBon(schar));
        s=(int)((float)s*((float)2+schar.t.MM[6].val*0.06+getCrit_dmg()));
        return s;
    }

    public int FinalCritDR(Char_sheet schar)
    {
        int s=FinalCrit(schar);
        if(school==0) s=(int)((float)s*schar.getPenDR());
        else if(school!=5) s=(int)((float)s*schar.getMR());
        return s;
    }

    public String setShot_info(Char_sheet schar)
    {
        Calc(schar);
        shot_info="";
        shot_info+=("\n*****"+name+"*****");
        if(tick==1 || name=="Explosive Shot") shot_info+=("\nAverage Hit: "+(avg_hit/getev_hit())+"\nAverage Crit: "+(avg_crit/getev_crit()));
        else shot_info+=("\nAverage Damage: "+(dmg_done/getev())*tick+"\nTick Damage: "+(dmg_done/getev()));
        //shot_info+=("\nOptimal Damage: "+opt_dmg+"\nOptimal DR: "+opt_dmg_dr);
        //shot_info+=("\nMana Cost: "+mana+"\nDamage Per Mana: "+getDPM());
        shot_info+="\n";
        return shot_info;
    }

    public int getev_hit() {
        if(ev_hit>0) return ev_hit;
        else return 1;}
    public int getev_crit() {
        if(ev_crit>0) return ev_crit;
        else return 1;}
    public int getev() {
        if(ev>0) return ev;
        else return 1;}

    public float getCrit_dmg() {return (float)crit_dmg/100;}
    public float getBon_dmg() {return (float)bon_dmg/100;}

    public float getBase_cast() {return (float)base_cast/100;}
    public void setBase_cast(float s) {base_cast = (int)(s*100);}

    public float getAct_cast() {return (float)act_cast/100;}
    public void setAct_cast(float s) {act_cast = (int)(s*100);}

    public float getDPS() {return (float)dps/100;}
    public void setDPS(float s) {dps = (int)(s*100);}

    public float getDPM() {return (float)dpm/100;}
    public void setDPM(float s) {dpm = (int)(s*100);}

}
